define(
		[ "PDUtilDir/util", "PDUtilDir/slidebar",
				"PDUtilDir/inputSelect",
				"PDUtilDir/fileupload/singleFileUpload", "Date", "DateCN",
				"css!DateCss",
				"css!AppPathDir/order/orderDoneInfos/views/css/css" ],
		function(Util, Slidebar, inputSelect) {
			function updateSupportInit($scope, $compile) {
				return new updateSupport($scope, $compile);
			}
			function updateSupport($scope, $compile) {
				this.$scope = $scope;
				this.$compile = $compile;
				this.cache = {
					visitors: new Array()
				}
			}
			updateSupport.fn = updateSupport.prototype;
			updateSupport.fn.digest = function() {
				this.$scope.$digest();
			};
			updateSupport.fn.selectVisitor = function(id) {
				var visitors = this.entity.visitors, len = visitors.length;
				for(var i = 0; i < len; i++){
					if(id == visitors[i].id){
						this.cache.visitors.push(visitors[i]);
						this.entity.visitors.splice(i,1);
//						this.cache.isOk = true;
//						this.$scope.updateOrderForm.totalAmount.$setViewValue(this.cache.isOk);
						break;
					}
				}
			};
			updateSupport.fn.run = function(data) {
				var _this = this, tmp_status = _this.$scope.cache.status;
				_this.entity = $.extend({
					statusName : '未知'
				}, data);
				if (tmp_status){
					for (var i = 0; i < tmp_status.length; i++) {
						if (tmp_status[i].dictCode == _this.entity.status) {
							_this.entity.statusName = tmp_status[i].dictName;
						}
					}
				}
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/order/orderDoneInfos/views/update.html",
//					close : true,
					$scope : this.$scope,
					$compile : this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			updateSupport.fn.initialization = function() {
				var _this = this;
				//游客列表
			    $.ajax({
					url : getServer() + "/flea/hclv/visitor/order/listOrderVisitors.htmls",
					data: {
				    	model : _this.entity.orderNo,
				    },
					success : function(data) {
						_this.entity.visitors = data.data;
						_this.digest();
					}
				});
			    $("#updateOrderForm .body ul").mCustomScrollbar({
					axis : "y",
					theme: "minimal-dark"
				});
			};
			updateSupport.fn.save = function() {
				var _this = this;
				$.ajax({
					url : getServer() + "/flea/hclv/visitor/order/updateOrder.htmls",
					data : {
						'model' : JSON.stringify({
							id : _this.entity.id,
							orderNo : _this.entity.orderNo,
							totalAmount: this.entity.totalAmount,
							visitors: _this.cache.visitors,
							comment : _this.entity.comment
						})
					},
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.$scope.grid.refresh();
						Util.alert(data.message);
						_this.slidebars.close();
					}
				});
			};
			return updateSupportInit;
		});